cmake_minimum_required(VERSION 3.10)
project(DecryptionClient CXX)

# Set C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Project configuration
set(PROJECT_VERSION "1.0.0")
set(EXECUTABLE_NAME "decryption_client")

# Source files
set(CLIENT_SOURCES
    src/main.cpp
)

add_compile_options(-g)
message(STATUS "Building in Debug mode with -g flag")

# Include directories
include_directories(
    include
)

# Create the executable
add_executable(${EXECUTABLE_NAME} ${CLIENT_SOURCES})

# Go server integration
option(BUILD_GO_SERVER "Build Go server component" OFF)
if(BUILD_GO_SERVER)
    # Find make program
    find_program(MAKE_EXECUTABLE make REQUIRED)
    
    # Add custom target to build Go server using existing Makefile
    add_custom_target(uds_server
        COMMAND ${MAKE_EXECUTABLE} -C ${CMAKE_SOURCE_DIR}/src/server
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/server
        COMMENT "Building Go server using Makefile"
        VERBATIM
    )
    
    # Install the server binary
    install(PROGRAMS ${CMAKE_SOURCE_DIR}/src/server/uds_server DESTINATION bin)
endif()
